package com.atguigu.gulimall.test.firefox;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class MainDriver {
  public static void main(String[] args) {
    test1();
  }
  
  
  public static void test1(){
    System.setProperty("webdriver.gecko.driver", "E:\\firefoxDriver\\geckodriver.exe");
    System.setProperty("webdriver.firefox.bin", "D:\\fixfox\\firefox.exe");
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("marionette",true);
    //原文出自【易百教程】，商业转载请联系作者获得授权，非商业请保留原文链接：https://www.yiibai.com/selenium/selenium-webdriver-running-test-on-firefox-browser-gecko-driver.html
    WebDriver driver= new FirefoxDriver(capabilities);
  
    // Launch Website
    // driver.navigate().to("http://fumacrom.com/HIod");
  
    // Click on the Custom Search text box and send value
//      driver.findElement(By.name("kw")).sendKeys("java教程");
//      driver.findElement(By.id("submit")).click();
  
    // Click on the Search button
    // driver.findElement(By.className("article-list-item-txt")).click();//原文出自【易百教程】，商业转载请联系作者获得授权，非商业请保留原文链接：https://www.yiibai.com/selenium/selenium-webdriver-running-test-on-firefox-browser-gecko-driver.html
  
    try {
      Thread.sleep(100000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
  
  public static  void test2(){
        System.setProperty("webdriver.chrome.driver",  "E:\\firefoxDriver\\geckodriver.exe");
        WebDriver webDriver = null;
        try{
           ChromeOptions options = new ChromeOptions();
           options.addArguments("--headless"); //无浏览器模式
           // options.addExtensions(new File(env.getProperty("path.chrome.proxy")));//增加代理扩展
           webDriver = new ChromeDriver(options);//实例化
       }catch(Exception e){
          e.printStackTrace();
       }finally{
         //使用完毕，关闭webDriver
           if(webDriver != null){
                webDriver.quit();
             }
       }
  }
}
